#include "../include/DictProducer.h"
#include "../include/SplitToolCppJieba.h"
#include "../include/Configuration.h"
#include "../include/DirScanner.h"
#include "../include/PageLib.h"
#include "../include/tinyxml2.h"
#include <iostream>


using std::cout;
using std::endl;

/*
void test0()
{
    DictProducer dict; // 创建DictProducer对象

    // 处理英文语料文件
    dict.dealEN("../yuliao/The_Holy_Bible.txt");

    // 打印处理结果
    for (const auto &word : dict._dictEN)
    {
        cout << word.first << " : " << word.second << endl;
    }
}
*/

/*
void test1(){    
    // 创建分词工具
    SplitToolCppJieba splitter;
    
    // 测试句子
    std::string sentence = "我来到北京清华大学";
    std::vector<std::string> words = splitter.cut(sentence);
    
    // 输出分词结果
    std::cout << "分词结果：" << std::endl;
    for(const auto& word : words) {
        std::cout << word << " ";
    }
    std::cout << std::endl;
}
*/


void test2() {
    // 创建派生类对象
    SplitToolCppJieba* splitter = new SplitToolCppJieba();
    
    // 创建 DictProducer 对象，传入分词工具指针
    DictProducer dict(splitter);
    
    // 加载停用词
    dict.loadStopWords("../yuliao/stop_words_zh.txt");

    // 假设有一个中文语料文件路径
    std::string chineseFilePath = "../yuliao/C3-Art0019.txt";

    // 处理中文语料文件
    dict.dealCN(chineseFilePath);

    /*
    // 打印map容器
    for (const auto &word : dict._dictCN) {
        cout << word.first << " : " << word.second << endl;
    }
    */

    /*
    // 打印vector容器中的处理结果
    std::cout << "\n词典内容：" << std::endl;
    for (const auto &word : dict._vecCN) {
        std::cout << word.first << " : " << word.second << std::endl;
    }
    */

    // 打印索引map容器的内容
    std::cout << "\n索引内容:" << std::endl;
    for (const auto &index : dict._indexCN) {
        std::cout << index.first << " :";
        for (const auto &wordIndex : index.second) {
            std::cout << wordIndex << " ";
        }
        // 打印具体的词
        cout << std::endl;
        for (const auto &wordIndex : index.second) {
            std::cout << dict._vecCN[wordIndex].first << " ";
        }
        std::cout << "\n" << std::endl;
    }
}


void test3(){
    // 创建分词工具对象（因为是英文处理，可以传入 nullptr）
    SplitTool* splitter = nullptr;
    DictProducer dict(splitter);

    // 处理英文语料文件
    dict.dealEN("../yuliao/The_Holy_Bible.txt");

    // 打印索引map容器的内容
    std::cout << "\n英文索引内容:" << std::endl;
    for (const auto &index : dict._indexEN) {
        std::cout << "字母 " << index.first << " 出现在以下单词中:" << std::endl;
        for (const auto &wordIndex : index.second) {
            std::cout << dict._vecEN[wordIndex].first << "(" << dict._vecEN[wordIndex].second << ") ";
        }
        std::cout << "\n" << std::endl;
    }
}

void test4(){
    /*
    //测试配置文件的map容器
    Configuration* config = Configuration::getInstance();
    auto configMap = config->getConfigMap();

    cout << "文章路径列表：" << endl;
    for (const auto& entry : configMap) {
        cout << entry.first << " : " << entry.second << endl;
    }
    */

    //测试DirScanner类_file容器是否存储了路径
    DirScanner scanner;
    scanner.traverse(""); // 假设配置文件路径已经在Configuration类中设置

    const auto& files = scanner.getFiles();
    std::cout << "存入的XML文件路径列表:" << std::endl;
    for (const auto& file : files) {
        std::cout << file << std::endl;
    }
}







int main(){
    cout << "test" << endl;
    return 0;
}
